package com.tourlaid.mamagerment.action.pc

import com.tourlaid.mamagerment.ao.pc.StockOutAo
import com.tourlaid.mamagerment.entity.ResponseData
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import javax.annotation.Resource

/**
 * Created by xiaoyongge on 2017/7/23.
 * 入库单
 */
@RestController
@RequestMapping("/tld/admin/stockout")
class StockOutAction {

    @Resource
    var stockOutAo: StockOutAo? = null

    @RequestMapping("/list.json")
    fun list(shopId: Long?, goodsId: Long?,
             @RequestParam(defaultValue = "1") pageNo: Int,
             @RequestParam(defaultValue = "10") pageSize: Int,
             callback: String):
            String {
        val ResponseData = stockOutAo!!.list(shopId, goodsId, pageNo, pageSize);
        return ResponseData.toJson(callback)
    }

    @RequestMapping("/insert.json")
    fun insert(controlNo: String?, shopId: Long?, stockInId: Long?, stock: Int?,
               callback: String): String {
        stockOutAo!!.insert(controlNo, shopId, stockInId, stock);
        return ResponseData<String>().toJson(callback)
    }

    @RequestMapping("/detail.json")
    fun detail(stockOutId: Long,
               callback: String): String {
        var stockOutVo = stockOutAo!!.detail(stockOutId);
        return ResponseData(stockOutVo).toJson(callback)
    }

    @RequestMapping("/update.json")
    fun update(stockOutId: Long?, shopId: Long?, controlNo: String?,
               callback: String): String {
        stockOutAo!!.update(stockOutId, shopId, controlNo);
        return ResponseData<String>().toJson(callback)
    }

    @RequestMapping("/delete.json")
    fun delete(stockOutId: Long?,
               callback: String): String {
        stockOutAo!!.delete(stockOutId);
        return ResponseData<String>().toJson(callback)
    }
}